#!/bin/bash

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${SCRIPT_DIR}"

REPO_ROOT="$(git rev-parse --show-toplevel)"
cd "${REPO_ROOT}"/python

export TZ=UTC

if [ -n "${1}" ]; then
TRADING_DATE="${1}"
else
TRADING_DATE="$(TZ=UTC date '+%Y%m%d')"
fi

source ~/miniconda3/etc/profile.d/conda.sh
conda activate coin2_motion_env

export PYTHONVERSION=python3.8
source ${CONDA_PREFIX}/opt/hyper/bin/envsetup.sh
source ${CONDA_PREFIX}/opt/papyrus/bin/envsetup.sh
export BATCH_INSTALL_ROOT=${BATCH_INSTALL_ROOT:-"${REPO_ROOT}/external"}

./pyrunner coin/support/feed_tool/feed_stats/app/feed_stats_motion/feed_stats_single_process_runner.py \
  --trading_date="${TRADING_DATE}" \
  --machine="feed-05.ap-northeast-1.aws" \
  --mea="Spot.Binance.v1" \
  --recipe="l1_realtime" \
  --group="m" \
  --worker=0 \
  --need_plot=False \
  --need_feed_csv=True \
  --run_for_raw=False \
  --duration="PT24H"

conda deactivate
